package com.pastquestion;

import java.util.Scanner;

public class Main10g {
	static int[][] a;
	static int res = 0;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int m = scan.nextInt();
		int len = scan.nextInt();
		int n = scan.nextInt();
		a = new int[m + 1][n + 1];
		for (int i = 0; i < len; i++) {
			int x = scan.nextInt();
			int y = scan.nextInt();
			a[y][x]++;
		}
		for (int i = 0; i < a.length; i++) {
			int ans = 0;
			for (int j = 0; j < a[i].length; j++) {
				if(a[i][j] >= 1)
					ans = a[i][j]*2;
				else
					ans--;
			}
			if(ans > 3)
				res++;
		}
		System.out.println(res);
	}
}
